import os
from os.path import isfile, isdir

print(os.getcwd())
for fname in os.listdir(r'./数据分析案例'):#括号里传入子目录名称
    print(fname)

print(os.getcwd())

# print(os.mkdir(os.getcwd()+'\\temp'))
# print(os.chdir(os.getcwd()+'\\temp'))
print('--------------')

# os.chdir('temp')
print(os.getcwd())

print(os.listdir())
os.chdir(r'E:\PythonProject1')
print(os.getcwd())
# os.rmdir('temp')
print(os.listdir())

print('======================')
os.startfile('cmd.exe')#启动指定程序

#使用深度优先方法，挖掘指定目录下所有文件
def listDirDepthFirst(dirtctory):
    for subpath in os.listdir(dirtctory):
        path = os.path.join(dirtctory,subpath)
        if isfile(path):
            print(path)
        elif isdir(path):
            listDirDepthFirst(path)

listDirDepthFirst(r'E:\PythonProject1')



